#ifndef LOG_H
#define LOG_H

//*********************************************************************
// INCLUDES
//*********************************************************************

#include <memory>				// Needed for singleton class
using namespace std;

//*********************************************************************
// CLog
//*********************************************************************

class CLog  
{
public:
	explicit CLog();

	enum _Openmode
	{	// constants for file opening options
		_Openmask = 0xff};

	static const _Openmode EnableTimestamp = (_Openmode)0x01;
	static const _Openmode TimeAsFilename = (_Openmode)0x02;
	static const _Openmode OverWrite = (_Openmode)0x04;
	static const _Openmode app = (_Openmode)0x08;
	static const _Openmode trunc = (_Openmode)0x10;
	//static const _Openmode _Nocreate = (_Openmode)_IOS_Nocreate;
	//static const _Openmode _Noreplace = (_Openmode)_IOS_Noreplace;
	//static const _Openmode binary = (_Openmode)_IOSbinary;

	bool FlagContain(_Openmode bit)
	{
		if ((OpenFlag | bit) == OpenFlag)
			return true;
		else return false;
	}
	// Functions
	static CLog * Instance();
	
	void CreateLog(string sFilepath, string sFilename, _Openmode flag);
	void Log(string sText);
	void SetEnableTimestamp(bool bEnable = true);
	void CloseLog();


private:
	// Constructor & destructor
				// Private constructor because singleton!

	// Functions
	string GetTime();
	string GetDate();
	string Filepath;
	string Filename;
	// Variables
	static std::auto_ptr<CLog> sm_inst;
	ofstream * m_pLogFile;
	_Openmode    OpenFlag;

};

// End of redefinition protection
#endif // LOG_H